home *** CD-ROM | disk | FTP | other *** search
/ ftp.whtech.com / ftp.whtech.com.tar / ftp.whtech.com / datasheets and manuals / Hardware / WHT / scsi / dsr_sources_2_2001 / open < prev    next >
Text File  |  2006-10-19  |  4KB  |  165 lines

  1. * I/O Op Code 0 - OPEN
  2. *
  3. * This module will check the attributes of the file to open,
  4. * make sure everything's OK and open the file.  A maximum of
  5. * 16 files can be open at one time.  If a user attempts to
  6. * open a 17th file, an error is returned
  7. *
  8. * Date: April 21, 1995 (One week before Lima!)
  9. *
  10. * Author: David Nieters
  11. *
  12.  
  13.  
  14. * We will begin by making sure the file isn't open already
  15.  
  16. OPEN0
  17.        ANDI R12,>FF00
  18.        AI   R12,24
  19.  
  20.        LDCR @B02,4            Select RAM bank 2
  21.        BLWP @IFO
  22.        JNE  OPEN1
  23.  
  24.        BL   @DSRERR           File is already open / Error!
  25.        DATA >0200             Bad open attribute
  26.  
  27. * Make sure that there are not too many files open already
  28. OPEN1
  29.        LDCR @B02,4           Select RAM bank 2
  30.        LI   R1,OFCASH
  31. OPEN1A C    @4(R1),@ZERO
  32.        JEQ  OPEN2
  33.        AI   R1,100
  34.        CI   R1,>6000
  35.        JL   OPEN1A
  36.        BL   @DSRERR          There are too many files open!
  37.        DATA >0400            Out of space error
  38.  
  39. * If the file is being opened in relative mode, assume
  40. * the record format is fixed.
  41. OPEN2  LDCR @ZERO,4
  42.        MOVB @PABBUF+1,R1
  43.        ANDI R1,>0100
  44.        JEQ  OPEN3
  45.        MOVB @PABBUF+1,R1
  46.        ANDI R1,>EFFF
  47.        MOVB R1,@PABBUF+1
  48.  
  49. * See how the file is to be opened and branch to the
  50. * right piece of code.
  51.  
  52. OPEN3
  53.        MOV  @PABBUF,R1
  54.        ANDI R1,>0006          Mask out the mode of operation
  55.        MOV  @OPENJT(R1),R2    Get address of open routine
  56.        B    *R2
  57.  
  58. * This jump table gives the entry point for each of the 4
  59. * modes a file can be open
  60.  
  61. OPENJT DATA OPENUP            Update mode
  62.        DATA OPENOU            Output mode
  63.        DATA OPENIN            Input mode
  64.        DATA OPENAP            Append Mode
  65.  
  66.  
  67. * Here are some subroutines used by OPEN
  68. *
  69.  
  70. **
  71. *
  72. *  OSCASH - OPEN SETUP CACHE
  73. *
  74. *  This procedure allocates a cache entry and fills in
  75. *  the following fields -
  76. *
  77. *  SCSI ID, Name Length, FDR bank, Buffer Bank, FDR Address,
  78. *  Buffer Address, Full file name, AU of FDR, File Open Attributes
  79. *
  80. *  It resets all other fields to zero.
  81. *
  82. **
  83.  
  84. OSCASH
  85.        LDCR @B02,4            Select RAM bank 2
  86.        LI   R4,OFCASH
  87.        LI   R3,>5000          FDR pointer
  88. OSC1   C    @4(R4),@ZERO      Is this cache entry used?
  89.        JEQ  OSC2              If not, we will use it
  90.  
  91.        AI   R3,>100           Otherwise, check next one
  92.        AI   R4,100
  93.        JMP  OSC1
  94. OSC2
  95.  
  96. * Now fill in the cache entry
  97. *
  98.        MOVB R6,*R4            SCSI ID
  99.        MOVB @B05,@2(R4)       FDR bank
  100.        MOV  R3,@4(R4)         FDR address
  101.        MOV  R3,R1             Compute bank of buffer (6 or 7)
  102.        ANDI R1,>0800
  103.        SRL  R1,3
  104.        AI   R1,>0600
  105.        MOVB R1,@3(R4)         Buffer Bank
  106.        ANDI R3,>0700          Compute buffer address
  107.        SLA  R3,1
  108.        AI   R3,>5000
  109.        MOV  R3,@6(R4)         Buffer address
  110.  
  111. * Now move the file name to the cache entry.  While we are
  112. * moving it, we will compute the file name's length.  While
  113. * the length isn't used now, in a future version of the
  114. * DSR, it can use the length to quickly search through the
  115. * cache entries to find the right match
  116.  
  117.        CLR  R1                R1 will compute file name length
  118.        AI   R4,8
  119.        LI   R3,NCB
  120.        LI   R0,40
  121. OSC3   CB   @SPACE,*R3
  122.        JEQ  OSC4
  123.        INC  R1                Increment file name length
  124. OSC4   MOVB *R3+,*R4+
  125.        DEC  R0
  126.        JNE  OSC3
  127.  
  128.        SWPB R1                Now put in the file name length
  129.        MOVB R1,@-47(R4)
  130.  
  131.        LDCR @B04,4            Select RAM bank 4
  132.        MOV  @SAVEAU,R0        Get AU of the FDR
  133.        LDCR @B02,4            Select RAM bank 2
  134.        MOV  R0,*R4+           Store the FDR's AU
  135.  
  136.        CLR  *R4+              Current AU (none)
  137.        CLR  *R4+              Sector within AU
  138.        CLR  *R4+              Pointer within buffer
  139.  
  140. * Get the file open attribute from the PAB
  141.  
  142.        LDCR @ZERO,4
  143.        MOVB @PABBUF+1,R1
  144.        ANDI R1,>0600
  145.        SRL  R1,1
  146.        LDCR @B02,4
  147.        MOVB R1,*R4+
  148.  
  149. * Now see if it is sequential or relative
  150.  
  151.        LDCR @ZERO,4
  152.        MOVB @PABBUF+1,R1
  153.        ANDI R1,>0100
  154.        LDCR @B02,4
  155.        MOVB R1,*R4+
  156.  
  157.        CLR  *R4+              Buffer size
  158.        CLR  *R4+              Buffer Modified
  159.        CLR  *R4+              Sector or Record #
  160.  
  161.        AI   R4,-64            Reset pointer
  162.        RT
  163.  
  164.        PAGE
  165.